package Table;


import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import java.awt.BorderLayout;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

import danhmuc.NhanVien;
import form.DSJ_FormMuaHang;
import form.DSJ_NhanVien;

import trangchu.UtilDelegate;
import trangchu.TrangChu;
import java.awt.Dimension;
import java.beans.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Vector;


public class TNhanVien extends JPanel {
    
	public JTable table;
	public DefaultTableModel model;
	String[][] data = {};
    String[] colunms = {"Mã NV","Họ Tên","Giới Tính","Ngày sinh","Địa Chỉ","Điện Thọai","Email","Số Tài Khoản","Ngân Hàng","Vai trò"};
	public TNhanVien(NhanVien nhanvien) {
		DSJ_NhanVien b = new DSJ_NhanVien();
		
		Vector list = b.getUsers();
		
		JScrollPane scrollPane = new JScrollPane();
    	model = new DefaultTableModel(data, colunms);
    	table = new JTable(model);
    	
    	//load xuong table
    	
    	Object[] oPerson = {
    			list.get(0).toString(),
    			list.get(1).toString(),
    			list.get(2).toString(),
    			list.get(3).toString(),
    			list.get(4).toString(),
    			list.get(5).toString(),
    			list.get(6).toString(),
    			list.get(7).toString(),
    			list.get(8).toString(),
    			list.get(9).toString()};
    	
    	this.model.insertRow(0, oPerson);
    	
    	
		//kich thuoc
		
		TableColumn col = table.getColumnModel().getColumn(0);		col.setPreferredWidth(60);
		TableColumn col1 = table.getColumnModel().getColumn(1);		col1.setPreferredWidth(196);
		TableColumn col2 = table.getColumnModel().getColumn(2);		col2.setPreferredWidth(80);
		TableColumn col3 = table.getColumnModel().getColumn(3);		col3.setPreferredWidth(90);
		TableColumn col4 = table.getColumnModel().getColumn(4);		col4.setPreferredWidth(230);
		TableColumn col5 = table.getColumnModel().getColumn(5);		col5.setPreferredWidth(130);
		TableColumn col6 = table.getColumnModel().getColumn(6);		col6.setPreferredWidth(200);
		TableColumn col7 = table.getColumnModel().getColumn(7);		col7.setPreferredWidth(120);
		TableColumn col8 = table.getColumnModel().getColumn(8);		col8.setPreferredWidth(100);
		TableColumn col9 = table.getColumnModel().getColumn(9);		col9.setPreferredWidth(150);
		
		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		setLayout(new BorderLayout(0, 0));
		scrollPane.setViewportView(table);
		add(scrollPane);
			
	}

}
